part of '../index.dart';

class _Appbar extends StatelessWidget {
  const _Appbar({required this.controller, this.onSearch});
  final TextEditingController controller;
  final VoidCallback? onSearch;

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      bottom: false,
      child: Row(
        children: [
          Padding(
            padding: const EdgeInsets.only(left: 10, right: 10),
            child: Transform.flip(
              flipX: Tools.isAr,
              child: Image.asset(Images.icArrowLeft, width: 25, height: 25),
            ),
          ).onTap(Navigator.of(context).pop),
          Container(
            constraints: const BoxConstraints(maxHeight: 40),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(99),
            ),
            child: Row(
              children: [
                Padding(
                  padding: const EdgeInsets.only(left: 10, right: 5),
                  child: Image.asset(
                    Images.icChatSearch,
                    width: 25,
                    height: 25,
                  ),
                ),
                Expanded(
                  child: TextField(
                    controller: controller,
                    textAlignVertical: TextAlignVertical.center,
                    style: const TextStyle(fontSize: 13),
                    textInputAction: TextInputAction.search,
                    onSubmitted: (value) => onSearch?.call(),
                    decoration: InputDecoration(
                      contentPadding: EdgeInsets.zero,
                      filled: true,
                      fillColor: Colors.transparent,
                      border: OutlineInputBorder(
                        borderRadius: BorderRadius.circular(99),
                        borderSide: BorderSide.none,
                      ),
                    ),
                  ),
                )
              ],
            ),
          ).expanded,
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 15),
            child: Text(
              T.current.c_search,
              style: const TextStyle(
                color: Color(0xFF8A72FE),
                fontSize: 16,
                fontWeight: FontWeight.w500,
              ),
            ),
          ).onTap(onSearch)
        ],
      ),
    );
  }
}
